Skip to content

FIX-2113: a steer reaches the turn that answers, and a task runs one turn at a time in its session - #3696

Merged
jhoffner merged 6 commits into
mainfrom
fix/FIX-2113
Oct 23, 2026
Merged

jhoffner merged 6 commits into
mainfrom
fix/FIX-2113

Conversation

@jhoffner

@jhoffner jhoffner commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

The problem

Alice steers a routed task while the task waits on research it filed: "Also use the word X". The steer is taken, but the finished draft does not carry X. In the closure walk this happened on 3 of 3 runs. In one run the task also stalled for about two minutes before it completed.

There are two causes, and this PR fixes both.

  1. Later turns lost the steer. The steer starts a turn at once, and that turn gets the steer as its message. The session does not keep that message, and the turn showed the steer nowhere else. When the research ends, its notice wakes a new turn in the same session, and that turn writes the draft. It never saw the steer.
  2. Two turns planned at once, and the task stalled. The steer's turn filed a plan step in a session of its own and waited for it. While it waited, it did not hold the session, so the research notice's turn ran beside it and filed a step too. The two plans shared the session's one plan board. The task stalled until a lease ran out (about 120 s).

What this does

  • Part 1. The steer's turn now shows each steer it takes as a line in the task's session, from its sender ("Message from alice: …"). A model call that takes a steer mid-run already does this. Every later turn in that session reads the steer.
  • Part 2: a notice's turn and a steer's turn wait for a turn that waits on its own step.
    • A request whose plan has a step in a session of its own marks the session, under its own request id, until it answers.
    • While another live request holds a mark, a notice stays owed, and a steer's turn admits nothing.
    • When the marked request answers, it sends the waiting notices at once, after the task's check.
    • A request that died holds nothing.

Cost (the coordinator's call): a result that comes back while another turn of the task waits on its own step is acted on later, after that turn answers.

What's asked of you

Nothing here is yours to decide. The coordinator decided part 2.

Parts worth reviewing closely

  • anotherTurnWaitsOnItsPlan and the planWaitingRequests marks in packages/workforce/src/conversation-board/plan.ts.
  • The defer option and deferredAt in orchestration's notice code (task-settled-entry.ts, task-notice.ts, pass.ts).
  • admitOwnTask's unlessAnotherTurnWaits (task-admission.ts), which the steer entry uses, and sendWaitingNotices in board.ts.

FIX-2113 · epic FIX-2056 · found by FIX-2087 · draft, for review; do not merge until approved

Docs note: the apps/docs change (orchestration/task-board.md: the "Waiting on tasks it filed" case and the line on steers shown in the session) has the docs-editor's revisions. It needs that pass again after this push.

How to review this: a bug fix on the direct route

This is a bug fix on the direct route: there is no spec and no spec PR, because the hard part was the diagnosis and it happened in code. This PR is the only gate, so unlike a spec-backed change, the approach is in scope — nothing here was signed off upstream.

Most valuable here: the diagnosis chain — does the repro actually reproduce the reported failure, is the named cause the real one, does the fix address that cause rather than the symptom, and does the regression test fail without the fix? Then the second path (the legacy shape, the null boundary, the concurrent case, the cancel path).

In scope to challenge: where the guard was placed, any behaviour change a user could notice, and whether this should have been a spec'd feature instead of a fix.

Engineering calls
  • Why a second serialization, beside the engine's reply line. A notice and a steer turn already defer on the session's reply-line key. A request gives that key back when it parks: a parked request holds nothing while it waits (FIX-2082), and keeping the key across a park would also block the notices that must run while a turn waits on a person (FIX-2077). So a turn parked on its own step needs a mark the key can't give.
  • Part 1 shows the steer as a line, the way the mid-run take does (showTakenSteers). The other way, keeping the steer turn's message as a user message, needs an engine change: userMessage is a pure function of the entry's input, and the steers are taken inside the block.
  • The mark is session state, keyed by request. It is not a read of the plan ledger: a request reads a ledger as the snapshot it first took, and an early read made the notice's own plan wait on a step another request had finished. Each request sets and clears only its own key. So a hold request (the work entry, a chat turn) that plans beside a marked one can't overwrite or clear its mark. Such a request is not gated itself: only a notice's turn and a steer's turn wait.
  • Only a step in a session of its own marks the session. An inline step runs inside its request, which holds the session's line.
  • The steer gate is in the admission, not a new step. In-flight steer turns replay by step path (docs/architecture/execution-and-errors.md), so the entry's steps are as they were.
  • A held notice is not a failed delivery. It stays owed and records deferredAt, and its age (which ends it as undeliverable past maxDebtAgeMs) counts from then. Resends while it waits stay bounded by the existing backoff, at most one every 5 minutes per owed notice. The marked request's answer drops that backoff (resendNowPatch) and runs the pass. Notice order is otherwise as it was (FIX-2077, FIX-2078, FIX-2082). A request waiting on a person or on getTask does not mark the session.
  • Not reachable today: a host with no record of ended requests holds no durable wait. A step session: "new" is refused there, so no request marks the session.
  • New public surface: taskSettledEntry({ defer }) and resendNowPatch, documented in the orchestration README in their own paragraph. Changeset: patch, for @flow-state-dev/orchestration and @flow-state-dev/workforce.
Everything else: evidence

Part 1, red then green. packages/workforce/test/steer-while-filed-work-open.test.ts, "reaches the turn that answers after the work ends, and is taken once". Without the fix, the notice's model call has the steer turn's answer in its history but not the steer. With the fix: PASS.

Part 2, model-free (same file, "runs one turn of the task at a time"). On a durable host, the steer's turn files a step session: "new", held 9 s. A second steer arrives while it waits. The research ends meanwhile, and its notice's turn files a step too.

  • Without the notice gate: the stall ("timed out waiting for the task to complete").
  • Without the steer gate: the second steer's turn runs beside the waiting turn and the task stalls (the test times out).
  • Without the send at the answer: expected 6769 to be less than 2500 (the notice waited for its next backoff).
  • With all three: PASS. The research's turn runs within 2.5 s after the steer turn answers. It reads the steer, works its own step, and the task completes once, on attempt 1.

Units:

  • "whether another turn of the session waits on its plan" covers own, none, live, dead, and one dead one live. With the waits.ended check removed it is red: expected true to be false.
  • orchestration/test/tasks/notice-defer.test.ts runs taskSettledEntry({ defer }) on the real engine. A held notice runs nothing and stays owed with deferredAt; one not held runs and is acknowledged. With defer ignored it is red: the block ran.
  • task-notice.test.ts covers resendNowPatch and the age counting from deferredAt.

Closure goal (goals/workforce-coordination/runs-on-one-task/ from fix/FIX-2087, real model, on 24744afaf, before this review push): j2:steer-shows PASS, with no stall. That run's model did not file a step from the steer turn, so part 2 is covered by the model-free test above.

Other goals, all PASS on this head: task-board/every-ending-reaches-its-filer, task-board/settles-when-its-work-is-over, task-board/waits-on-a-task-it-filed, task-tools/steer-and-follow-up.

Checks: pnpm typecheck PASS, run with TURBO_FORCE: turbo's cache had replayed a stale orchestration .d.ts locally. pnpm lint PASS · pnpm fallow:ci PASS · node scripts/check-retired-terms.mjs PASS · orchestration 2077 tests PASS · workforce 1557 tests PASS.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VaN4uTiYqiabCbsFLWM52A


Note

Medium Risk
Changes task-board concurrency, notice delivery timing, and steer/session message behavior on Workforce boards; orchestration adds defer semantics that integrators may rely on.

Overview
FIX-2113 fixes steers being lost on later turns and tasks stalling when multiple turns plan at once on a Workforce conversation board.

Steer visibility: The steer turn now records taken steers as sender lines in the task session (same pattern as mid-run takes), so the notice-driven turn that finishes after filed work still sees the message in session history.

One turn at a time: When a request’s plan has a step in its own session (session: "new"), it marks planWaitingRequests until that turn answers. While another request holds a live mark, onTaskSettled defers (notice stays owed, noticeDeferred:* resets max-debt age) and steer admission uses unlessAnotherTurnWaits. When the waiting plan answers, sendWaitingNotices clears resend backoff via resendNowPatch and triggers a pass so deferred notices run immediately after the task check.

Orchestration API: taskSettledEntry({ defer }), exported resendNowPatch, and pass logic using noticeTimes(...).since instead of due-only for undeliverable age. Docs/changesets updated.

Reviewed by Cursor Bugbot for commit 29e1542. Configure here.

…n (FIX-2113)

A steer sent while a task waits on the work it filed starts a turn at
once, which takes the steer as its message. That message is not kept in
the session, and the take showed nothing, so the turn that answers once
the work ends (the notice's, a later request in the same session) never
read the steer, and the draft lacked what it asked for.

The steer turn's take now shows the steers it takes as lines from their
senders, as a model call's take already does, so every later turn in the
session reads them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VaN4uTiYqiabCbsFLWM52A
@vercel

vercel Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Actions Updated
flow-state-dev-docs Ignored Ignored Oct 23, 2026 12:39pm UTC
flow-state-dev-kitchen-sink Ignored Ignored Oct 23, 2026 12:39pm UTC
flow-state-dev-ui Ignored Ignored Preview Oct 23, 2026 12:39pm UTC

Request Review

@linear-code

linear-code Bot commented Oct 23, 2026

Copy link
Copy Markdown

FIX-2113

@cursor

cursor Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: 435010b5-efe2-4d3c-abf5-a82d926ba893)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VaN4uTiYqiabCbsFLWM52A
A steer's turn that files a step in a session of its own waits on it,
and while it waits it doesn't hold the session. The research notice's
turn then ran beside it and planned too, over the session's one plan
ledger, and the task stalled until a lease ran out.

Now a request whose plan has a step in a session of its own marks the
session (its state, `planWaitingRequest`) until it answers. While another
request holds that mark, a notice is left owed (`taskSettledEntry`'s new
`defer`) and a steer's turn runs nothing. When the marked request
answers, after the task's check, it drops the backoff on the notices
left owed (`resendNowPatch`) and runs the session's pass, so they are
heard at once, one turn at a time. A request that died holds nothing.

The mark is session state, not a read of the plan ledger: a request
reads a ledger as the snapshot it first took, and an early read made
the notice's own plan wait on a step another request had finished.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VaN4uTiYqiabCbsFLWM52A
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VaN4uTiYqiabCbsFLWM52A
@cursor

cursor Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: 94af9e66-b52b-46d4-8d9c-81dc14fcab5b)

@jhoffner jhoffner changed the title FIX-2113 (part 1): a steer sent while a task waits on its filed work reaches the turn that answers FIX-2113: a steer reaches the turn that answers, and a task runs one turn at a time in its session Oct 23, 2026

@jhoffner jhoffner left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of part 2 (24744afaf, the delta since 3f92a61)

Lenses: correctness, coherence, restraint. Head reviewed: 3942aad08.

Verdict: the diagnosis holds, and the two pieces the test exercises are proven. Nothing here strands a session for good on a durable host. There are three 🟡 to settle before this leaves draft: an in-flight steer turn at deploy, the single-slot mark, and deferred notices aging out. The steer gate also needs a test.

Red checks I ran (steer-while-filed-work-open.test.ts, "runs one turn of the task at a time")

Removed Result
defer on the notice entry ❌ timed out waiting for the task to complete. Proves the notice gate.
resendNowPatch in sendWaitingNotices ❌ expected 5580 to be less than 2500. Proves the send-at-answer.
steer busy gate (forced false) ✅ still passes. Steer gate untested.
.tap(endPlanWaiting) ✅ still passes, because waits.ended covers it.

The dead-request branch (waits.ended → true) and orchestration's taskSettledEntry({ defer }) have no unit test of their own.

Findings

Finding Where
🟡 BP-030: the steer entry's restructure moves every step of an in-flight steer turn. Replay is keyed by structural path, so a steer turn parked on its own step at deploy (this PR's own scenario) won't resume cleanly. Keep the shape: do the check inside take, or append it after the existing steps. inline, steer.ts:231
🟡 The mark is one slot, last writer wins, and hold entries aren't gated. A follow-up or chat turn can overwrite it and clear it early, which reopens the gate while the first request still waits. The docs line "one turn at a time" also says more than the code does. inline, plan.ts:310
🟡 A deferred notice still ages toward undeliverable (24 h maxDebtAgeMs), with a no-op resend about every 5 min while it waits. inline, task-settled.ts:365
🟡 Tests: the steer gate, the dead-request path and defer itself are unproven (table above). Add a case where a second steer arrives while the mark stands, and one where the marked request fails. —
🟡 Coherence, a second way to serialize turns. A session-state mark now sits beside the concurrency arbiter's reply-line key, which already serializes notice and steer turns but lets go on a park. This is a bug-route PR, so per the review skill's job check, that belongs in the ask. "What's asked of you: nothing" should become one line on why the key can't be held across a park, or why a mark is better than doing so. PR body
🟣 ended === undefined → true fails closed. That's unreachable today, because session: "new" needs waits, but it's worth a comment. inline, plan.ts:153

Considered and clean

  • Mark on a cancel, error or crash path: no explicit clear, but waits.ended treats failed, aborted, incomplete and interrupted-not-driven-again as ended (wait-chain.ts:235). So a dead request holds nothing, and the notices it turned away go out on their normal backoff. That costs some delay but nothing is lost.
  • Two gated requests racing to set the mark: notice and steer turns are serialized on the defer reply-line key, and decidePlan writes the mark before the drain parks. No race among gated entries; the ungated case is above.
  • BP-030, session state: the new key is optional and nullable, and old sessions read as unmarked. A request parked under old code replays decidePlan's record, so it never marks. It keeps the old behaviour once, and that's acceptable.
  • sendWaitingNotices scope: it reads this session's own filing partition only, so it doesn't reset backoff on notices owed to other sessions.
  • BP-007: resendNowPatch, defer and afterPlan have JSDoc, and the orchestration README documents both new APIs.
  • BP-022: patch is correct, not minor. Pre-1.0, additive API is patch (best-practices.md BP-022, .changeset/README.md:17). The fragment cites FIX-2113.
  • Restraint: the surface is proportionate. endPlanWaiting isn't load-bearing, but it's cheap hygiene (see the plan.ts:153 note).

Generated by Claude Code

…n, keep held notices (FIX-2113)

Review of #3696:

- The steer turn's gate moves into its admission (`admitOwnTask`'s
  `unlessAnotherTurnWaits`), so the entry's step paths are as they were
  and an in-flight steer turn replays across a deploy.
- The plan mark is keyed by request (`planWaitingRequests`): each
  request sets and clears only its own key, so two that plan in one
  session never overwrite or clear each other's. Keys left by dead
  requests hold nothing, and the next plan clears them.
- A notice a busy session turns away records when (`deferredAt` on its
  marker), and its age, which ends it as undeliverable, counts from
  then: being turned away is no failed delivery. Its resends stay
  bounded by the 5-minute backoff cap.
- Tests: a second steer while the steer's turn waits on its step; the
  dead-request branch; `taskSettledEntry`'s `defer` on its own; the age.
- Docs: task-board.md's message cases (narrowed to notice and steer
  turns) and the orchestration README's own paragraph on `defer` and
  `resendNowPatch`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VaN4uTiYqiabCbsFLWM52A
@cursor

cursor Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: b14b42b5-55a4-4be3-9b2f-31fc3e42e9da)

Copy link
Copy Markdown
Collaborator Author

Stand-in review and docs-editor round: all addressed in cdcb493. Each finding has a reply on its thread.

  • 🟡 Replay paths: the gate is now in the steer entry's admission, so no step moved.
  • 🟡 One-slot mark: the mark is keyed by request, and each request sets and clears only its own key. The docs now say only notice and steer turns wait.
  • 🟡 Deferred notice lost: a held notice records deferredAt, and its age counts from there. Resends stay capped at one every 5 minutes.
  • 🟡 Untested paths: there are tests now for a second steer during the wait (red with the gate off), the dead-request branch (red with the check off), and orchestration's defer on its own (red with defer ignored).
  • 🟡 Engineering calls now say why the reply-line key can't be held across a park.
  • 🟣 Comment on the unreachable missing-waits host: added.
  • Docs-editor:
    • task-board.md:94 rewritten and narrowed.
    • README: defer and resendNowPatch now have their own paragraph, which defines the resend backoff. The README has no export table to update.
    • task-board.md:101 now reads "Unless it arrived before the task started".
  • Changeset: patch.

Generated by Claude Code

@jhoffner jhoffner left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stand-in delta re-review of 3942aad08..cdcb49340 (one commit).

Verdict: three of the four 🟡 from last round are fixed properly: the steer gate's shape, the single-slot mark, and the aging of held notices. The open one is the tests. The per-request mark and the new aging rule are both unpinned: I reverted each and every test still passed.

Checked and clean

  • The steer entry has main's step shape. git diff $(merge-base main) -- steer.ts shows the same .tap(admission) → .step(take) → .stepIf(run) → .tapIf(noteTaskAnswer) → .tap(settleWake) chain. Only two arguments differ: the admission's options and the ctx passed to takeRunningSteers. No replay path moved, so the BP-030 concern from last round is closed. While a mark is live, the admission admits nothing, take returns SKIP, and settleWake leaves the wake because the row still waits on "steer". That is what main does for an un-admitted start.
  • The per-request mark is safe. Each request writes and clears only its own key, through setStateRecord / deleteStateRecord. endPlanWaiting deletes only ctx.request.identity.id. The dead-key sweep deletes only keys that waits.ended answers true for, and a dead request never writes again, so racing it is harmless. Growth is bounded: one live key per in-flight plan request, plus dead keys left since the last plan, which that plan sweeps. ended answers true for a missing record (pruned by retention), so a deleted request can't pin a key. Old sessions have nothing to tolerate (BP-030): the single-slot key never reached main.
  • deferredAt can't keep a notice owed forever on its own. A notice can be turned away indefinitely only while anotherTurnWaitsOnItsPlan is true, which needs a marked request that hasn't ended. The drain does re-wait at each deadline, so a step that never ends keeps that wait, and the notice, alive. That is the acceptable case. When the marked request dies, ended returns true (failed / aborted / incomplete, or interrupted and not driven again). The gate opens and the notice goes out at its next resend. That resend can be up to 5 min later, because a dead request never applies resendNowPatch. The delay is acceptable; nothing is lost.
  • Two red checks hold. With { unlessAnotherTurnWaits: true } removed, "runs one turn of the task at a time" goes red (timeout at 40 s), so the steer gate is now pinned. With deferredNoticePatch not written, notice-defer.test.ts case 1 must go red, since it asserts deferredAt (checked by reading the test, not run).
  • BP-007 / BP-022. deferredNoticePatch, noticeTimes().since, OwedMarker.deferredAt, markedRequests and admitOwnTask's new option all have JSDoc. None are exported publicly (only resendNowPatch is), and the README covers the new aging rule under "Holding a notice back". The patch changesets are right for this.

Findings

  • 🟡 Nothing pins the per-request mark or the new aging rule. All three mutations below ran in an isolated worktree and every test stayed green:

    Mutation Result
    setStateRecord replaced with patchState({ planWaitingRequests: { [me]: true } }), the old last-writer-wins workforce 1557/1557 pass
    dead-key sweep removed, and endPlanWaiting wiping every key workforce 1557/1557 pass
    pass.ts back to tooOld(times.due) orchestration 2077/2077 pass

    The unit test of anotherTurnWaitsOnItsPlan covers the reader only, not the writers. noticeTimes().since is tested, but nothing tests that payBoardDebts uses it. Two small cases would close this: two requests that each mark and then each end, where the first one's end leaves the second's key; and a payBoardDebts call with maxDebtAgeMs where a notice whose due is old but whose deferredAt is recent is not marked undeliverable.

  • 🟣 deferredNoticePatch rewrites the whole marker from the entry's row snapshot. If a resend (resentRecord) or a clearNotice lands between that read and this write, the stale copy wins. A lost resend count only shortens the backoff. A cleared marker comes back and the notice is sent again, and on Workforce the noticeKey dedupe catches it. It's benign today, but anyone else who passes defer would see the block run twice. Writing only deferredAt, or re-reading just before the write, would close it.

  • 🟣 The sweep can drop a key that will come back to life. ended answers true for a request that is interrupted and not driven yet. If another plan in the session sweeps that key, and the sweeper then re-drives the request into its step's wait, it waits with no mark, so the gate stays open for the rest of that wait. Without the sweep, the gate would close again once it was driven. This needs a crash between decidePlan's mark and the drain's park, with a second plan in the window, so it's narrow. A one-line comment would do.

  • 🟣 planWaitingRequests isn't in SESSION_BOARD_SERVER_OWNED. As far as I can tell, a caller's seed is stripped by the flow's stateSchema, which doesn't declare the key, so I didn't find a way in. But a seeded key naming another session's request would read as "not ended" forever, and that is the one way a notice is held forever with no live wait. Listing it as server-owned makes that explicit (BP-031).

The coherence ask from last round, a mark rather than holding the reply-line key across a park, is a PR-body item. I didn't re-check it here.


Generated by Claude Code

…age (FIX-2113)

Delta review of #3696:

- The mark's writers are `markPlanWaiting` / `clearPlanWaiting`, and a
  test has two requests mark one session and end in either order: the
  first to end leaves the other's key, and the gate stays shut until both
  end; a dead request's key is dropped by the next plan. Red with the
  writer back to last-writer-wins, and with the sweep removed and the
  clear wiping every key.
- `payBoardDebts` with the 24 h maximum debt age doesn't end a notice
  whose due time is old but which a busy session turned away a minute
  ago. Red with the pass back to `tooOld(times.due)`.
- The turned-away time is a record beside the marker
  (`noticeDeferred:<attempt>:<ending>`), as a resend record is, not a
  rewrite of the marker from a stale snapshot; callers' metadata can't
  write it.
- `planWaitingRequests` is server-owned session state (BP-031).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VaN4uTiYqiabCbsFLWM52A

Copy link
Copy Markdown
Collaborator Author

Delta re-review 5628219978: addressed in 29e1542.

  • 🟡 Unpinned mark and aging (fixed). Two new tests, each red under your mutation:
    • Per-request mark. "keeps each request's mark its own…" covers markPlanWaiting / clearPlanWaiting, the writers now pulled out of the plan's handlers. Two requests mark one session and end in either order. The first to end leaves the other's key, and the gate stays shut until both end. A dead request's key is dropped by the next plan.
      • Writer back to last-writer-wins (patchState({ planWaitingRequests: { [me]: true } })): red, expected [] to deeply equal [ 'req-e' ].
      • Sweep removed and the clear wiping every key: red, expected [] to deeply equal [ 'req-b' ].
    • Aging. pass.test.ts "doesn't end a notice a busy session turned away lately…" runs payBoardDebts with the 24 h maximum debt age. A notice due a day and two minutes ago, turned away a minute ago, stays owed and is sent again. The same notice never turned away ends. With pass.ts back to tooOld(times.due): red, expected { at: 86520000, … } to be undefined.
  • 🟣 deferredNoticePatch rewriting the marker (fixed, it was cheap). The turned-away time is now a record beside the marker, noticeDeferred:<attempt>:<ending>: { at }, the same way a resend record is kept. The write never touches the marker, so a stale snapshot can't bring back a cleared marker or drop a resend count. withoutNoticeMarkers strips the new prefix from callers' metadata.
  • 🟣 Server-owned (done). planWaitingRequests is now in SESSION_BOARD_SERVER_OWNED (BP-031), so a caller's create can't seed a key.
  • 🟣 Interrupted-but-not-yet-driven sweep (accepted). It needs a crash between decidePlan's mark and the drain's park, plus a second plan in that window. The worst case is a gate left open for the rest of that one wait. The trade-off is now noted in the comment on markPlanWaiting.

Checks: orchestration 2078 tests and workforce 1558 tests PASS; typecheck (forced past turbo's cache), lint and fallow:ci PASS.


Generated by Claude Code

@cursor

cursor Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: 4b508548-29b8-4aee-b1d1-33cc14e24b93)

@jhoffner
jhoffner marked this pull request as ready for review October 23, 2026 12:50
@jhoffner
jhoffner merged commit 2d13fab into main Oct 23, 2026
20 of 22 checks passed
@jhoffner
jhoffner deleted the fix/FIX-2113 branch October 23, 2026 12:50
@cursor

cursor Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: d24c4675-f3e9-44cf-a74a-ebee3343c8c0)

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplify / architecture pass (FIX-2113)

Verdict: approve. The concurrency story is the right shape for the invariant (“one task turn at a time in its session” + “the notice turn sees steers from history”). I don’t see a materially simpler design that preserves durable waits, steer admission, and notice backoff without re‑inventing the pass rail.

What had to exist (and did)

Mechanism Role
planWaitingRequests + anotherTurnWaitsOnItsPlan Cross-request signal while a session: "new" plan step is in flight — can’t live in request state alone
taskSettledEntry.defer + deferredAt / since Reuses existing owed-notice + max-age semantics instead of a second queue
takeRunningSteers(..., ctx) on the steer turn Minimal fix for notice turn reading session history
afterPlan + resendNowPatch + pass Needed so a turned-away notice doesn’t sit behind multi-minute resend backoff after a ~9s plan step (second harness test)

Where complexity crept in (follow-ups, not blockers)

  1. Three wires for one predicate — defer, unlessAnotherTurnWaits, and sendWaitingNotices all express “session busy for another plan wait.” Consider a single exported helper (e.g. conversationSessionTurnBusy) colocated with the marks, and optionally extract sendWaitingNotices out of board.ts next to task-settled.ts / task-admission.ts.
  2. sendWaitingNotices is broader than the bug — it clears backoff for every row with any owed notice, then triggers a full pass. Safer narrowings (if you touch this again): only rows with deferredAt, or only when !anotherTurnWaitsOnItsPlan.
  3. Duplicated stale-mark cleanup — decidePlan prunes dead keys via waits.ended; anotherTurnWaitsOnItsPlan interprets the same marks. One shared pruneEndedPlanWaitingMarks would reduce drift.
  4. Comment duplication — FIX-2113 narrative is repeated across board.ts, steer.ts, task-admission.ts, task-settled.ts, and orchestration README; one canonical module header is enough.
  5. Harness cost — the 40s / 9s sleep test is valuable but heavy; most of backoff/immediate-resend is already covered in notice-defer.test.ts / task-notice.test.ts if you ever want to slim CI.

Alternatives considered (not recommended here)

  • Single session turn serializer — one lock checked by work, steer, and notice — cleaner mentally, but a new primitive that must compose with AFTER_REPLY_CONCURRENCY and existing wakes; too wide for this fix.
  • Only engine concurrency — doesn’t encode “plan turn still open across requests” without session marks.
  • Separate noticeDeferred:* sidecar (early sketch) — HEAD’s deferredAt on the owed marker is simpler; keep that.

Skipped (uncertain / product)

  • Whether ended === undefined should gate closed (true) vs open for minimal test hosts — document the host contract in JSDoc rather than changing semantics without an inventory.
  • Adding planWaitingRequests to SESSION_BOARD_SERVER_OWNED — only if client session seeding can overwrite handler sessionStateSchema keys today (I didn’t prove that either way).

Nice reuse of afterTaskCheck, admitOwnTask, and takeRunningSteers; orchestration/workforce boundaries look intentional.

Open in Web View Automation 

Sent by Cursor Automation: Review For Best Approach

execute: async (_input, ctx) => {
await afterTaskCheck(ctx as never, async () => {
const own = await conversationLedgerAt(ctx as never, await filingSessionIdOf(ctx.session));
const owed = (own?.list() ?? []).filter((row) => noticeDueAt(row) !== undefined);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplify (optional): This filters every row with any owed notice, clears all noticeResent:* backoffs that exist, then runs a full pass — on every plan answer. That’s broader than “notices we deferred while anotherTurnWaitsOnItsPlan.”

If this ever causes surprise (unrelated rows on a busy conversation), consider narrowing to markers with deferredAt, or gating the pass on !await anotherTurnWaitsOnItsPlan(ctx) so you only flush when the session is actually free.

@@ -775,7 +776,32 @@ export function defineConversationBoard(options: ConversationBoardOptions) {
);

/** The flow's planning: its turns, wrapped so the steps they file run in their request (FIX-2076). */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two adjacent block comments (FIX-2076 one-liner + FIX-2113 block) — merging into one short header would match the “one canonical doc” goal and shrink noise in an already large file.

// filed `session: "new"` is refused there, so no request marks the session;
// reading a mark anyway, take it as live.
const ended = ctx.requestHost?.waits?.ended;
if (ended === undefined) return true;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When requestHost.waits.ended is missing, this returns true (gate closed). That’s conservative for production hosts with durable waits, but minimal harnesses without ended will defer steers/notices whenever a mark exists. Worth a line in the exported JSDoc so callers know this predicate assumes a wait host — not necessarily a behavior change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants